<template>
  <div>
    <list v-show="paneValue==1" @router-pane="getPaneValue" @pane-back="back" ref="listPane"/>
    <detail v-show="paneValue==2" @router-pane="getPaneValue" ref="detailPane"/>
  </div>
</template>

<script>

    import Detail from './Details'
    import List from './List';

    export default {
        name: "Tabs",
        components:{Detail,List},
        data() {
            return {
                paneValue: 1,
                height:0,
            }
        },
        methods:{
            //获取父组件中isDisable
            isDisable(isDisabled){
                this.$refs.listPane.isDisable(isDisabled);
                this.$refs.detailPane.isDisable(isDisabled);
            },
            back(paneValue,id){
                this.$emit('router-pane',paneValue,id)
            },
            getPaneValue(paneValue,basicId,id){
                this.paneValue = paneValue;
                this.initLoadHeight(this.height);
                if(this.paneValue==1){
                    this.$nextTick(()=>{
                        this.$refs.listPane.init(basicId);
                    })
                }else if(this.paneValue==2){
                    this.$nextTick(()=>{
                        this.$refs.detailPane.getId(basicId,id);
                    })
                }
            },
            //加载高度
            initLoadHeight(height){
                this.height = height;
                if(this.paneValue==1){
                    this.$nextTick(()=>{
                        this.$refs.listPane.initLoadHeight(this.height);
                    })
                }else if(this.paneValue==2){
                    this.$nextTick(()=>{
                        this.$refs.detailPane.initLoadHeight(this.height);
                    })
                }
            },
            initBasicId(basicId){
                if(this.paneValue==1){
                    this.$nextTick(()=>{
                        // this.$refs.listPane.initLoadHeight(this.height);
                        this.$refs.listPane.initBasicId(basicId);
                    })
                }
                // else if(this.paneValue==2){
                //     this.$nextTick(()=>{
                //         this.$refs.detailPane.initLoadHeight(this.height);
                //         // this.$refs.detailPane.initBasicId(basicId);
                //     })
                // }
            }
        }
    }
</script>

<style scoped>

</style>